<template>
  <div class="mobile-filter-form">
    <div class="filter-header" @click="toggleCollapse">
      <span>筛选条件</span>
      <i :class="['el-icon-arrow-down', {'is-active': !isCollapsed}]"></i>
    </div>
    <div class="filter-content" :class="{'is-collapsed': isCollapsed}">
      <slot></slot>
      <div class="filter-actions">
        <el-button type="primary" @click="handleSearch" :loading="loading">查询</el-button>
        <el-button @click="handleReset">重置</el-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
    name: 'MobileFilterForm',
    props: {
        loading: {
            type: Boolean,
            default: false
        }
    },
    data () {
        return {
            isCollapsed: false
        };
    },
    methods: {
        toggleCollapse () {
            this.isCollapsed = !this.isCollapsed;
        },
        handleSearch () {
            this.$emit('search');
        },
        handleReset () {
            this.$emit('reset');
        }
    }
};
</script>

<style lang="scss" scoped>
.mobile-filter-form {
  background-color: #fff;
  border-radius: 4px;
  margin-bottom: 15px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  overflow: hidden;

  .filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    font-weight: bold;
    cursor: pointer;
    border-bottom: 1px solid #ebeef5;

    i {
      transition: transform 0.3s;

      &.is-active {
        transform: rotate(180deg);
      }
    }
  }

  .filter-content {
    padding: 15px;
    transition: max-height 0.3s ease;
    max-height: 1000px;
    overflow: hidden;

    &.is-collapsed {
      max-height: 0;
      padding: 0 15px;
    }
  }

  .filter-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 15px;
  }
}
</style>
